/*
 * @Author: Gaoxs
 * @Date: 2023-04-07 15:12:06
 * @LastEditors: Gaoxs
 * @Description:
 */
import util from '@/utils'

import App from './App'

import { createPinia } from 'pinia'

import { createSSRApp } from 'vue'

// 引入 uv-ui 组件库
import uvUI from '@climblee/uv-ui'
import '@climblee/uv-ui/index.scss'

// 引入导航栏高度工具
import { initNavbarHeight } from '@/utils/navbar'

// 引入全局组件
import GlobalNavbar from '@/components/global-navbar/global-navbar.vue'
import PageContainer from '@/components/page-container/page-container.vue'

export function createApp() {
  const app = createSSRApp(App)
  app.use(util)
  app.use(createPinia())
  app.use(uvUI)

  // 注册全局组件
  app.component('GlobalNavbar', GlobalNavbar)
  app.component('PageContainer', PageContainer)

  // 全局初始化导航栏高度
  initNavbarHeight().then(() => {
    console.log('全局导航栏高度初始化完成')
  }).catch((error) => {
    console.error('全局导航栏高度初始化失败:', error)
  })

  return {
    app,
  }
}
